import os
import  time

import alert as alert
from selenium import webdriver
from selenium.webdriver.common.by import By

file="file:///" + os.path.abspath("../html4") + "/popup.html"
driver=webdriver.Chrome()
driver.get(file)

but=driver.find_elements(By.TAG_NAME,"button")
but[0].click()

#切换alert
time.sleep(2)
alert = driver.switch_to.alert
alert.accept() #确定

but[1].click()
alert = driver.switch_to.alert
time.sleep(2)
print(alert.text)
alert.dismiss() #取消

but[2].click()
alert = driver.switch_to.alert
time.sleep(2)
print(alert.text)





time.sleep(2)
driver.quit()